package com.imodia.checkoo.webtag;

import java.util.List;

import org.springframework.web.servlet.tags.RequestContextAwareTag;

import com.hsq.commons.util.BeanFactory;
import com.imodia.checkoo.bean.CmsAttachmentSourceBean;
import com.imodia.checkoo.service.CmsAttachmentSourceService;



public class AttachmentListTag  extends RequestContextAwareTag {
	private static final long serialVersionUID = -1764906844122921796L;
	private Integer newsId;
	

	public Integer getNewsId() {
		return newsId;
	}


	public void setNewsId(Integer newsId) {
		this.newsId = newsId;
	}


	@Override
	protected int doStartTagInternal() {
		CmsAttachmentSourceService cmsAttachmentSourceService = (CmsAttachmentSourceService) BeanFactory.getBean("cmsAttachmentSourceService");
		List<CmsAttachmentSourceBean> attachmentList = cmsAttachmentSourceService.listByArticleId(newsId);
		if(attachmentList.size()>0){
			pageContext.setAttribute("AttachmentListTag", attachmentList.get(0));
		}else{
			pageContext.setAttribute("AttachmentListTag", null);
		}
		return EVAL_BODY_INCLUDE;
	}
}
